const { Middleware, Order } = require("free-koa/decorator")

@Middleware
class Index {
    @Order(10)
    async init(ctx, next) {
        await next()
        if (ctx.status === 404) {
            ctx.body = "这是一个404"
        }
    }
    @Order(100)
    async catchError(ctx, next) {
        try {
            await next();
        } catch (error) {
            console.log(error)
            ctx.body = "捕获到异常";
        }
    }
}
module.exports = Index